<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" autoFlush="true"%>
<%@include file="/common/taglib.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<x:multiLanguage>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="../css/dialog.css" rel="stylesheet" type="text/css" />
<link href="../css/ddtabmenu_dialog.css" rel="stylesheet" type="text/css" />

<script src="common/fck_dialog_common.js" type="text/javascript"></script>
<script language="JavaScript" src="dialog.js"></script>
<script language="JavaScript" src="script.js"></script>
<script language="JavaScript" src="sequence.js"></script>

<script language="JavaScript" src='<s:url value="/script/jquery/jquery-1.4.2.js" />'></script>
<script language="JavaScript" src='<s:url value="/script/ddtabmenufiles/ddtabmenu.js" />'></script>

<SCRIPT language="JavaScript">
var dialog	= window.parent ;
var oEditor = dialog.InnerDialogLoaded() ;
// Gets the document DOM
var oDOM = oEditor.FCK.EditorDocument ;
var oActiveEl = dialog.Selection.GetSelectedElement() ;


function Ok() {
	if(ev_check()){
		oEditor.FCKUndo.SaveUndoStep() ;
		//var id=getFieldId();
		createRelStr(); // 保存值到processDescription
		
		var json = getFormJSON(); // 查看dialog.js
		json['className'] = "cn.myapps.core.dynaform.form.ejb.InputField";
		oActiveEl = CreateNamedElement(oEditor, oActiveEl, 'INPUT', json);		
		return true;
	}
}

//检查内容是否完成正确
function ev_check(){
   if(temp.name.value==''){
 	 alert("{*[page.name.notexist]*}");
	  return false;
   }
   return !checkStartChar(temp.name.value);
}

function checkStartChar(value){
	return IsDigit(value,"{*[page.name.startingit]*}");
}

function ev_onTextTypeChanged(value){
	//文本类型如果为只读是,显示“只显示文本”选项组
	if(value == 'readonly'){
		$('#nbr').show();
	} else {
		$('#nbr').hidden();
	}
	//文本类型如果为隐藏时,则隐藏脚本选项卡无效，不可操作
	if(value == 'hidden'){
		$('#hiddenValue').val("");
		$('#hiddenScript').attr("disabled", "disabled");
		$('#hiddenScriptEditor').disabled = "disabled";
		$('#hiddenValue').disabled = "disabled";
	} else {
		$('#hiddenScript').disabled = "";
		$('#hiddenScriptEditor').disabled = "";
		$('#hiddenValue').disabled = "";
	}
}

function ev_onTyepch() {
	$('#npTD').hide();
	$('#noneTD').hide();
	$('#npDiv').hide();
    if (document.getElementsByName('fieldType').value == 'VALUE_TYPE_NUMBER'){
    	$('#npTD').show();
    	$('#npDiv').show();
 	} else {
 		$('#noneTD').show();
 	}
}

$(function() {
	//初始值
	oEditor.FCKLanguageManager.TranslatePage(document) ;
	if ( oActiveEl && (oActiveEl.tagName == 'INPUT')) {
		setFormByObject(oActiveEl); // 查看dialog.js
		var items = HTMLDencode(oActiveEl.processDescription);
	    parseRelStr(items);
	}

	ddtabmenu.definemenu("tabs", "t1");
	ev_onTyepch();
	//initForm();
	modeChange($("input[name=editMode]:checked").val());
	SelectField( 'name' ); // 选中字段

	dialog.SetOkButton( true ) ;
	dialog.SetAutoSize( true ) ;
});
</script>

</HEAD>

<BODY>

<form name="temp">
	<div id="tabs" class="basictab">
		<ul>
			<li><a id="t1" rel="tabs-1">{*[Basic]*}</a></li>
			<li><a id="t2" rel="tabs-2">{*[Value_Script]*}</a></li>
			<li><a id="t3" rel="tabs-3">{*[Validate_Script]*}</a></li>
			<li><a id="t4" rel="tabs-4">{*[Hidden_Script]*}</a></li>
			<li><a id="t5" rel="tabs-5">{*[Hidden_Print_Script]*}</a></li>
			<li><a id="t6" rel="tabs-6">{*[ReadOnly_Script]*}</a></li>
		</ul>
	</div>	
	
	<div id="contents">	
		<div id="tabs-1">
			<!-- content1 -->
			<table border=1 cellpadding=3 cellspacing=1 class="content" id="content1" width="520px">
				<tr>
					<td>{*[Name]*}:</td>
					<td colspan="3">
						<input type="text" id="name" name="name"  onchange="checkStartChar(this.value);" class="store" size="20">
					</td>
				</tr>
				<tr>
					<td>{*[Textbox_Type]*}:</td>
					<td>
						<select onchange="ev_onTyepch()" name="fieldType" class="store">
							<option value="VALUE_TYPE_VARCHAR">{*[Text]*}</option>
							<option value="VALUE_TYPE_NUMBER">{*[Number]*}</option>
						</select>
					</td>
					<td class="commFont commLabel">{*[TextType]*}:</td>
					<td>
						<select name="textType" class="store">
							<option value="text">{*[Common]*}</option>
							<option value="password">{*[Password]*}</option>
							<option value="readonly">{*[Readonly]*}</option>
							<option value="hidden">{*[Hidden]*}</option>
						</select>
					</td>
				</tr>
				<tr>
					<td class="commLabel commFont">{*[Focus_Key]*}:</td>
					<td>
						<select name="fieldkeyevent" class="store">
							<option value="Tabkey">Tab</option>
							<option value="Enterkey">Tab or Enter</option>
						</select>
					</td>
					<td>
						<div id ='npDiv' style="display: none">{*[Format]*}:</div>
					</td>
					<td id="npTD" style="display: none">
						{*[eg]*}:##.##<br>
						<input type="text" name="numberPattern" size="13" class="store">
					</td>
					<td id="noneTD">&nbsp</td>
				</tr>
				<tr id="nbr" >
					<td>
						<font color="red">({*[Readonly]*})</font>{*[Only]*}{*[Show]*}{*[Text]*}:</td>
					<td colspan="3">
					    <input type="radio" name="borderType" value="false" checked class="store">{*[No]*}&nbsp;
						<input type="radio" name="borderType" value="true" class="store">{*[Yes]*}
					</td>
				</tr>
				<tr>
					<td align="center" colspan="4">
						<input type=checkbox name="refreshOnChanged" value="true" class="store">{*[Refresh]*}&nbsp;
						<input type=checkbox name="calculateOnRefresh" value="true" class="store">{*[Recalculate]*}&nbsp;
						<input type="checkbox" name="mobile" value="true" checked class="store"/>{*[Mobile]*}&nbsp;
					</td>
				</tr>
				<tr>
					<td>{*[Description]*}:</td>
					<td colspan="3"><textarea name="discript" style="width:100%;" rows="4" class="store"></textarea></td>
				</tr>
			</table>
		</div>
		<div id="tabs-2">
			<table border="1" cellpadding="3" cellspacing="1" class="content" id="content2" width="520px">
				<%@include file="commondialog.jsp"%>
			</table>
		</div>
		<div id="tabs-3">
			<table border="1" cellpadding="3" cellspacing="1" class="content" id="content3" width="520px">
					<tr>
						<td width="25%">
						<table>
							<tr>
								<td>
									<input type="checkbox" name="validateLibs" value="validateLibsId1" class="store"/>validateLibsName1
									<input type="checkbox" name="validateLibs" value="validateLibsId2" class="store"/>validateLibsName2
								</td>
							</tr>
						</table>
						</td>
						<td width="75%">
							<textarea name="validateRule" cols="75"  style="width:95%" rows="10" class="store"></textarea>
							<button style="border:0px;cursor: pointer;" onclick="openIscriptEditor('validateRule','{*[Script]*}{*[Editor]*}','{*[Validate_Script]*}','name','{*[Save]*}{*[Success]*}');"><img alt="Open with IscriptEditor" src="<s:url value='/resource/image/editor.png' />"/></button>
							</td>
					</tr>
				</table>
		</div>
		<div id="tabs-4">
			<table border="1" cellpadding="3" cellspacing="1" class="content" width="100%" id="content4" width="520px">
					<tr>
						<td>
							<textarea id="hiddenScript" name="hiddenScript" style="width:96%" rows="10" class="store"></textarea>
							<button id="hiddenScriptEditor" style="border:0px;cursor: pointer;" 
								onclick="openIscriptEditor('hiddenScript','{*[Script]*}{*[Editor]*}','{*[Hidden_Script]*}','name','{*[Save]*}{*[Success]*}');"><img alt="Open with IscriptEditor" src="<s:url value='/resource/image/editor.png' />"/></button>
						</td>
					</tr>
					<tr>
						<td>{*[hiddenValue]*}：<input id="hiddenValue" type="text" name="hiddenValue" class="store"/></td>
					</tr>
				</table>
		</div>
		<div id="tabs-5">
			<table border="1" cellpadding="3" cellspacing="1" class="content" width="520px"
					id="content5">
					<tr>
						<td><textarea name="hiddenPrintScript" style="width:96%" rows="10"></textarea>
						<button style="border:0px;cursor: pointer;" onclick="openIscriptEditor('hiddenPrintScript','{*[Script]*}{*[Editor]*}','{*[Hidden_Print_Script]*}','name','{*[Save]*}{*[Success]*}');"><img alt="Open with IscriptEditor" src="<s:url value='/resource/image/editor.png' />"/></button>
						</td>
					</tr>
					<tr>
						<td>{*[Print]*}{*[hiddenValue]*}：<input  type="text" name="printHiddenValue" class="store"/></td>
					</tr>
				</table>
		</div>
		<div id="tabs-6">
			<table border="1" cellpadding="3" cellspacing="1" class="content" width="520px" id="content6">
				<tr>
					<td><textarea name="readonlyScript" style="width:96%" rows="10" class="store"></textarea>
					<button style="border:0px;cursor: pointer;" onclick="openIscriptEditor('readonlyScript','{*[Script]*}{*[Editor]*}','{*[ReadOnly_Script]*}','name','{*[Save]*}{*[Success]*}');"><img alt="Open with IscriptEditor" src="<s:url value='/resource/image/editor.png' />"/></button>
					</td>
				</tr>
			</table>
		</div>
	</div>
</form>
</BODY>
</x:multiLanguage>
</HTML>
